package Code.Day7_20240924.com.dx.day07;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;

/**
 * @ClassName StudentIO
 * @Description TODO:
 * @Author 12994
 * @Date 2024/9/24 13:06
 * @Version 1.0
 **/
public class StudentIO extends MySchoolIO implements SqlIO {
    public static void main(String[] args) throws SQLException {
        StudentIO studentIO = new StudentIO();
        studentIO.getInfoByPwd();


        // 反射 Reflection
        Class cls = studentIO.getClass();
//        System.out.println(cls.getName());
//        System.out.println(cls.getSimpleName());
//        System.out.println(cls.getPackage().getName());
//        System.out.println(cls.isEnum());
    }

    public void getInfoByPwd() throws SQLException {
        StudentIO studentIO = new StudentIO();
        ResultSet rs;
        try (PreparedStatement ps = studentIO.getConn().prepareStatement(
                "SELECT StudentNo, LoginPwd, StudentName, Sex, GradeId," +
                        " Phone, Address, BornDate, Email, IdentityCard " +
                        "FROM student WHERE LoginPwd=? AND Sex=?")) {
            ps.setObject(1, "111111");
            ps.setObject(2, 1);
            rs = ps.executeQuery();
            while (rs.next()) {
                System.out.printf("StudentName: %S\n", rs.getString("StudentName"));
                System.out.printf("StudentNo: %S\n", rs.getString("StudentNo"));
            }
        }
    }
}
